<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>openCard</title>
    <script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js" >
    </script>
</head>
<body>

    账号:<input type="text" name="uid" id="uid1"/><br>
    密码:<input type="password" name="pwd" id="pwd1"/><br>
    确认密码:<input type="password" name="pwdrp" id="pwdrp1"/><br>
    年龄:<input type="text" name="age" id="age1"/><br>
    昵称:<input type="text" name="nickname" id="nickname1"/><br>
    邮箱:<input type="text" name="email" id="email1"/><br>
    <input type="button" id="submit2" value="注册"><span id="span2"></span>

    <script>
    $(function(){
        $("#submit2").click(function(){
            var uid1 = $("#uid1").val();
            var pwd1 = $("#pwd1").val();
            var pwdrp1 = $("#pwdrp1").val();
            var age1 = $("#age1").val();
            var nickname1 = $("#nickname1").val();
            var email1 = $("#email1").val();
            var user = {
                uid:uid1,
                pwd:pwd1,
                age:age1,
                nickname:nickname1,
                email:email1
            };
            $.ajax({
                type:"post",
                contentType: "application/json",
                url:"opencard",
                data:JSON.stringify(user),
                dataType:"json",
                success:function (data) {
                    if(data.result == "success"){
                        window.location.href='/index';
                    }else{
                        $("#span2").text("注册失败");
                    }
                }
            })
        })
    })
    </script>
</body>
</html>